﻿using System;
using System.Collections.Generic;
using System.Text;

using FreeFlow.Administration;
using System.Windows.Forms;

namespace FreeFlowAdministrator
{
  public class WorkflowVersionsAdaptor : Adaptor
  {
    private WorkflowVersionCollection versions;
    public WorkflowVersionsAdaptor(WorkflowVersionCollection versions)
    {
      this.versions = versions;
    }

    public override string Text
    {
      get 
      { 
        return "Versions (" + versions.Count + ")"; 
      }
    }

    public override object Object
    {
      get 
      { 
        return versions; 
      }
    }

    public override int ImageIndex
    {
      get
      {
        return 13;
      }
    }

    public override void AddChildren(TreeNode node)
    {
      foreach (WorkflowVersion version in versions)
      {
        TreeNode versionNode = TreeNodeFactory.CreateTreeNode(new WorkflowVersionAdaptor(version));
        node.Nodes.Add(versionNode);
      }
    }

    public override Control GetRenderer()
    {
      WorkflowVersionsControl control = new WorkflowVersionsControl();
      control.LoadVersions(versions);
      return control;
    }
  }
}
